# -*- coding: utf-8 -*-
Pms::Application.routes.draw do
  root "dashboard#index"

  resources :employees do
    member do
      get 'certificates' # 获取某个员工的所有证书
      get 'positions' # 获取某个员工的所有岗位
      get 'position_lost_certificates' # 获取某个员工所有岗位的缺失证书
      get 'contracts' # 获取合同
    end
  end

  resources :positions  # 岗位管理
  resources :certificates do# 证书类型管理
    member do
      get 'require_organs'
    end
    collection do
      get 'analysis'
    end
  end

  namespace :organization do
    resources :categories do# 组织机构类型管理
      member do
        get 'position_standard'
      end
    end
    resources :ranks # 组织机构等级管理
  end

  resources :organizations do # 组织管理
    collection do
      get 'tree'
    end
    member do
      post 'assignment_position_standard' # 为某个组织分配 持证要求单位
      get 'position_standard' #获取组织岗位配置
      get 'get_employee_and_positions'
      get 'require_certificate_organs'
    end
  end

  namespace :position do
    resources :natures
  end

  namespace :employee do
    resources :certificates do
      collection do
        get 'list_valid_certificates' # 获取所有过期证书
        get 'list_will_valid_certificates' #获取即将到期证书列表
        get 'will_valid_certificates_count'
        get 'query_will_certificates' #获取一定时间内到期的证书
      end
    end
    resources :positions
    resources :contracts do
      collection do
        get 'list_valid_contracts'
        get 'list_will_valid_contracts'
      end
    end
  end

  resources :position_certificate_standards do
    collection do
      get 'list_lost_certificate' # 获取所有岗位确实的证书
      get 'get_position_standards/:position_id' => "position_certificate_standards#get_position_standards"
    end
  end

  resources :require_certificate_organs
  resources :position_standard_assignments
  resources :organ_category_position_standards do
    collection do
      get 'query_position_standard/:category' => 'organ_category_position_standards#query_position_standard'
    end
  end
  resources :contract_types

  match '/logout' => 'application#logout', as: "logout", :via => [:get]
end
